package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @Author FengHuan Wang
 * @Date 2025/1/1 13:50
 * @Version 1.0
 */
@Slf4j
@Api(tags = "店铺操作相关接口")
@RestController("adminShopController")
@RequestMapping("/admin/shop/")
public class ShopController {
    private static final String SHOP_STATUS = "STATUS";
    @Autowired
    private RedisTemplate redisTemplate;

    /*店铺状态设置功能实现*/
    @PutMapping("/{status}")
    @ApiOperation("店铺状态设置")
    public Result setStauts(@PathVariable Integer status){
        log.info("开始设置店铺状态："+status);
        redisTemplate.opsForValue().set(SHOP_STATUS,status);
        return Result.success();
    }

    /*查询店铺状态功能实现*/
    @GetMapping("/status")
    @ApiOperation("查询店铺状态")
    public Result<Integer> getStauts(){
        log.info("商家开始查询店铺营业状态");
        Integer status = (Integer) redisTemplate.opsForValue().get(SHOP_STATUS);
        return Result.success(status);
    }
}
